import os.path

from Tools.Chunker import Chunker
from OpenAIUtils.PromptTemplate import PromptTemplate

class GeneticPrompt:
    def __init__(self, prompt_template, args):
        template_str = str(prompt_template)
        chunker = Chunker()
        chunks = chunker.run(template_str)
        self.chunks = chunks
        self.sequence = list(range(len(chunks)))
        self.scores = []

    def __str__(self):
        ret = ""
        for i in self.sequence:
            ret += self.chunks[i]+"\n"
        return ret

    def to_prompt_template(self):
        return PromptTemplate().from_string(str(self))

    def clear_scores(self):
        self.scores = []
